<?php
 require_once('../tcpdf/config/lang/eng.php');
 require_once('../tcpdf/config/tcpdf_config.php');
 require_once('../tcpdf/tcpdf.php');
class GFEReportCreater
{
    private $type;
    private $pdf;
	
//    public function GPEReportCreater($type)
//    { 
//       $this->type = $type;
//    }
    public function __construct($type) {
        $this->type = $type;
    }
 
    public function getContentFile()
    {
        if ($this->type == "Purchase")
            $filename = 'Purchase.template';
        else 
            $filename = "Refinance.template";
        
        if (!file_exists( $filename))
        {
            echo "Khong ton tai file $filename";
            exit();
        }
        
        return file_get_contents($filename);
    }
    public function formatCurrency($value)
    {
        $format_number = number_format($value, 2, '.', ',');
        return '$'.$format_number;
    }
    public function GeneratePurchasePDF($purchaseGFE)
    {
       //$purchaseGFE = new PurchaseGFE();
        $html = $this->getContentFile();
        $html = str_replace('[TRANSACTIONTYPE]', $this->type, $html);
        $html = str_replace('[STATE]', $purchaseGFE->getState()->getValue(), $html);

        if ($purchaseGFE->getCountyLocale() != null)                
            $html = str_replace('[COUNTY]', $purchaseGFE->getCountyLocale()->getName(), $html);
        else 
            $html = str_replace('[COUNTY]', '', $html);
        
        if ($purchaseGFE->getTownLocale() != null)                
            $html = str_replace('[LOCALE]', $purchaseGFE->getTownLocale()->getName(), $html);
        else 
            $html = str_replace('[LOCALE]', '', $html);

        if ($purchaseGFE->getState()->getName() != 'fl')
            $html = str_replace('[Primary Residence]','Primary Residence', $html);
        else 
            $html = str_replace('[Primary Residence]','Single family home', $html);

        if ($purchaseGFE->getPrimaryResidence() != null)
        {                
            if ($purchaseGFE->getPrimaryResidence()->getValue())
                $html = str_replace('[PRIMARYRESIDENT]','Yes', $html);
            else 
                $html = str_replace('[PRIMARYRESIDENT]','No', $html);
        }
        else 
            $html = str_replace('[PRIMARYRESIDENT]','', $html);

        $html = str_replace('[PURCHASEPRICE]',$this->formatCurrency($purchaseGFE->getPurchasePrice()), $html);


        $arrloan = $purchaseGFE->getLoanAmounts();
        $countloan = count($arrloan);
        if ($countloan ==1)
        {
            $html = str_replace('[LOAN1]',$this->formatCurrency($arrloan[0]), $html);
            $html = str_replace('[LOAN2]', '', $html);
        }
        else if ($countloan ==2)
        {
            $html = str_replace('[LOAN1]',$this->formatCurrency($arrloan[0]), $html);
            $html = str_replace('[LOAN2]',$this->formatCurrency($arrloan[1]), $html);
        }
        else 
        {
            $html = str_replace('[LOAN1]', '', $html);
            $html = str_replace('[LOAN2]', '', $html);
        }

        if ($purchaseGFE->isEnhancedCoverage())
            $html = str_replace('[ENHANCEDCOVERAGE]','Yes', $html);
        else 
            $html = str_replace('[ENHANCEDCOVERAGE]','No', $html);

        if ($purchaseGFE->getQualifiedFirstTimeBuyer() != null)
        {
            if ($purchaseGFE->getQualifiedFirstTimeBuyer()->getValue())
                $html = str_replace('[FIRSTTIMEBUY]','Yes', $html);
            else
                $html = str_replace('[FIRSTTIMEBUY]','No', $html);
        }
        else 
            $html = str_replace('[FIRSTTIMEBUY]','', $html);

        if ($purchaseGFE->getRequestedPayer() != null)
        {
            if ($purchaseGFE->getRequestedPayer()->getValue() == 'Default')
                $html = str_replace('[TRANFERTAX]', 'allocated per normal custom', $html);
            else
                $html = str_replace('[TRANFERTAX]',$purchaseGFE->getRequestedPayer()->getValue(), $html);
        }
        else 
            $html = str_replace('[TRANFERTAX]', '', $html);

        //*Add Title Charge 1001
        $buyerTotal = 0;
        $sellerTotal = 0;

        $titleServicesCost = $purchaseGFE->getPurchaseTitleInsuranceCost()->getTitleServicesCost();
        $line1001buyer = $titleServicesCost + $purchaseGFE->getPurchaseTitleInsuranceCost()->getLendersCost();

        $line1101Seller = $purchaseGFE->getPurchaseTitleInsuranceCost()->getSettlementFee();

        $line1001total = $line1001buyer + $line1101Seller;

        $html = str_replace('[TOTALSERVICE_BUYER_PAY]',$this->formatCurrency($line1001buyer), $html);
        $html = str_replace('[TOTALSERVICE_SELLER_PAY]',$this->formatCurrency($line1101Seller), $html);
        $html = str_replace('[TOTALSERVICE_TOTAL]',$this->formatCurrency($line1001total), $html);

        $buyerTotal += $line1001buyer;
        $sellerTotal += $line1101Seller;            

        $html = str_replace('[COMBINE_SERVICE_FEE]',$this->formatCurrency($titleServicesCost), $html);
        $html = str_replace('[COMBINE_SERVICE_TOTAL]',$this->formatCurrency($titleServicesCost), $html);

        $line1104 = $purchaseGFE->getPurchaseTitleInsuranceCost()->getLendersCost();
        $html = str_replace('[LENDER_VALUE]',$this->formatCurrency($line1104), $html);
        $html = str_replace('[LENDER_TOTAL]',$this->formatCurrency($line1104), $html);

        $line1103 = $purchaseGFE->getPurchaseTitleInsuranceCost()->getOwnersCost();
        $html = str_replace('[OWNER_VALUE]',$this->formatCurrency($line1103), $html);
        $html = str_replace('[OWNER_TOTAL]',$this->formatCurrency($line1103), $html);
        $buyerTotal += $line1103;            

        $html = str_replace('[TOTAL_INSURANCE_BUYER_PAY]',$this->formatCurrency($buyerTotal), $html);
        $html = str_replace('[TOTAL_INSURANCE_SELLER]',$this->formatCurrency($sellerTotal), $html);
        $html = str_replace('[TOTAL_INSURANCE]',$this->formatCurrency($sellerTotal + $buyerTotal), $html);

        $grandTotalBuyer = $buyerTotal;
        $grandTotalSeller = $sellerTotal;

        //*Add Gorvement  Recording and Transfer
        $transferTaxes = $purchaseGFE->getRecordationAndTransferTaxes();
        $buyerStateTax = $transferTaxes[0]->getStatePropertyTransferTax();
        $sellerStateTax = $transferTaxes[1]->getStatePropertyTransferTax();

        $buyerCountyTax = $transferTaxes[0]->getCountyPropertyTransferTax();
        $sellerCountyTax = $transferTaxes[1]->getCountyPropertyTransferTax();

        $buyerRecordationTax = $transferTaxes[0]->getRecordationTax();
        $sellerRecordationTax = $transferTaxes[1]->getRecordationTax();

        $buyerFees = $transferTaxes[0]->getFees();
        $sellerFees = $transferTaxes[1]->getFees();

        $buyerTotal = 0.0;
        $sellerTotal = 0.0;

        $buyerFeesTotal = 0.0;
        $sellerFeesTotal = 0.0;
        if ($buyerFees != null) {
            for ($i = 0; $i < count($buyerFees); $i++) {
                $buyerFeesTotal += $buyerFees[$i]->getAmount();
                $sellerFeesTotal += $sellerFees[$i]->getAmount();

                $buyerTotal += $buyerFees[$i]->getAmount();
                $sellerTotal += $sellerFees[$i]->getAmount();
            }
        }
        $totalFees = $buyerFeesTotal + $sellerFeesTotal;
        $buyerTaxTotal = 0.0;
        $sellerTaxTotal = 0.0;
        $totalStateTaxAmount = 0.0;
        if ($buyerStateTax != null) {
            $buyerTaxTotal += $buyerStateTax->getAmount();
            $sellerTaxTotal += $sellerStateTax->getAmount();
            $totalStateTaxAmount = $buyerStateTax->getAmount() + $sellerStateTax->getAmount();
        }
        $totalCountyTaxAmount = 0.0;
        if ($buyerCountyTax != null) {
            $buyerTaxTotal += $buyerCountyTax->getAmount();
            $sellerTaxTotal += $sellerCountyTax->getAmount();
            $totalCountyTaxAmount = $buyerCountyTax->getAmount() + $sellerCountyTax->getAmount();
        }
        $totalRecordationTaxAmount = 0.0;
        if ($buyerRecordationTax != null) {
            $buyerTaxTotal += $buyerRecordationTax->getAmount();
            $sellerTaxTotal += $sellerRecordationTax->getAmount();
            $totalRecordationTaxAmount = $buyerRecordationTax->getAmount() + $sellerRecordationTax->getAmount();
        }
        $buyerTotal += $buyerTaxTotal;
        $sellerTotal += $sellerTaxTotal;
        $taxTotal = $buyerTaxTotal + $sellerTaxTotal;
        $total = $buyerTotal + $sellerTotal;

        $html = str_replace('[RECORD_FEE_BUYER_PAY]',$this->formatCurrency($buyerFeesTotal), $html);
        $html = str_replace('[RECORD_FEE_SELLER_PAY]',$this->formatCurrency($sellerFeesTotal), $html);
        $html = str_replace('[RECORD_FEE_TOTAL]',$this->formatCurrency($totalFees), $html);

        if ($buyerCountyTax != null) {
            $html = str_replace('[COUNTY_TRANFER_TAX_BUYER_PAY]',$this->formatCurrency($buyerCountyTax->getAmount()), $html);
            $html = str_replace('[COUNTY_TRANFER_TAX_SELLER_PAY]',$this->formatCurrency($sellerCountyTax->getAmount()), $html);
            $html = str_replace('[COUNTY_TRANFER_TAX_TOTAL_PAY]',$this->formatCurrency($totalCountyTaxAmount), $html);
        }
        else 
        {
            $html = str_replace('[COUNTY_TRANFER_TAX_BUYER_PAY]', '', $html);
            $html = str_replace('[COUNTY_TRANFER_TAX_SELLER_PAY]', '', $html);
            $html = str_replace('[COUNTY_TRANFER_TAX_TOTAL_PAY]', '', $html);
        }
        if ($buyerStateTax != null) {                
            $html = str_replace('[STATE_TRANFER_TAX_BUYER_PAY]',$this->formatCurrency($buyerStateTax->getAmount()), $html);
            $html = str_replace('[STATE_TRANFER_TAX_SELLER_PAY]',$this->formatCurrency($sellerStateTax->getAmount()), $html);
            $html = str_replace('[STATE_TRANFER_TOTAL_PAY]',$this->formatCurrency($totalStateTaxAmount), $html);  
        }
        else
        {
            $html = str_replace('[STATE_TRANFER_TAX_BUYER_PAY]', '', $html);
            $html = str_replace('[STATE_TRANFER_TAX_SELLER_PAY]', '', $html);
            $html = str_replace('[STATE_TRANFER_TOTAL_PAY]', '', $html);  
        }

        if ($buyerRecordationTax != null) {
            $html = str_replace('[RECODATION_TAX_BUYER_PAY]',$this->formatCurrency($buyerRecordationTax->getAmount()), $html);
            $html = str_replace('[RECODATION_TAX_SELLER_PAY]',$this->formatCurrency($sellerRecordationTax->getAmount()), $html);
            $html = str_replace('[RECODATION_TAX_TOTAL_PAY]',$this->formatCurrency($totalRecordationTaxAmount), $html);    
        }
        else
        {
            $html = str_replace('[RECODATION_TAX_BUYER_PAY]', '', $html);
            $html = str_replace('[RECODATION_TAX_SELLER_PAY]', '', $html);
            $html = str_replace('[RECODATION_TAX_TOTAL_PAY]', '', $html);    
        }

        $html = str_replace('[GOV_TAX_BUYER_PAY]',$this->formatCurrency($buyerTaxTotal), $html);
        $html = str_replace('[GOV_TAX_SELLER_PAY]',$this->formatCurrency($sellerTaxTotal), $html);
        $html = str_replace('[GOV_TAX_TOTAL_PAY]',$taxTotal, $html); 

        $html = str_replace('[TOTAL_GOV_RECODING_TRANSFER_BUYER]',$this->formatCurrency($buyerTotal), $html);
        $html = str_replace('[TOTAL_GOV_RECODING_TRANSFER_SELLER]',$this->formatCurrency($sellerTotal), $html);
        $html = str_replace('[TOTAL_GOV_RECODING_TRANSFER_TOTAL]',$this->formatCurrency($total), $html);  

        $grandTotalBuyer += $buyerTotal;
        $grandTotalSeller += $sellerTotal;

        $line1301 = $purchaseGFE->getPurchaseTitleInsuranceCost()->getLocationSurvey();

        $html = str_replace('[LOCATION_SURVEY_BUYER]',$this->formatCurrency($line1301), $html);
        $html = str_replace('[LOCATION_SURVEY_SELLER]',$this->formatCurrency($line1301), $html);  
        $html = str_replace('[TOTAL_ADD_CHARGE_BUYER]',$this->formatCurrency($line1301), $html);
        $html = str_replace('[TOTAL_ADD_CHARGE_TOTAL]',$this->formatCurrency($line1301), $html); 

        $grandTotalBuyer += $line1301;

        $html = str_replace('[ALL_TOTAL_BUYER]',$this->formatCurrency($grandTotalBuyer), $html);  
        $html = str_replace('[ALL_TOTAL_SELLER]',$this->formatCurrency($grandTotalSeller), $html);
        $html = str_replace('[ALL_TOTAL]',$this->formatCurrency($grandTotalBuyer + $grandTotalSeller), $html);

        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Danh');
        $pdf->SetTitle('TCPDF Table');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');            
        // set header and footer fonts
        $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        //set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        //set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        //set image scale factor
        //set some language-dependent strings
        //$pdf->setLanguageArray($l);
        // ---------------------------------------------------------
        // set font
        $pdf->SetFont('dejavusans', '', 8);
        // add a page
        $pdf->AddPage();		
        $pdf->writeHTML($html, true, true, true, false, '');
        $pdf->lastPage();		
        $pdf->Output($this->type. $purchaseGFE->getState()->getValue().".pdf", 'I');
    }
    public  function GenerateRefinancePDF($refinanceGFE, $titleInsuranceCost, $reissue)
    {        
        $transferTaxes = $refinanceGFE->getRecordationAndTransferTaxes();
        $titleServices = $refinanceGFE->getTitleServices();
        $mobileClosingCost = $refinanceGFE->getMobileClosingCost();

        $grandTotalBuyer = 0.0;
        $grandTotalSeller = 0.0;
        
        //$refinanceGFE = new RefinanceGFE();
        $html = $this->getContentFile();
        $html = str_replace('[TRANSACTIONTYPE]', $this->type, $html);
        $html = str_replace('[STATE]', $refinanceGFE->getState()->getValue(), $html);

        if ($refinanceGFE->getCountyLocale() != null)                
            $html = str_replace('[COUNTY]', $refinanceGFE->getCountyLocale()->getName(), $html);
        else 
            $html = str_replace('[COUNTY]', '', $html);
        
        if ($refinanceGFE->getTownLocale() != null)                
            $html = str_replace('[LOCALE]', $refinanceGFE->getTownLocale()->getName(), $html);
        else 
            $html = str_replace('[LOCALE]', '', $html);

        if ($refinanceGFE->getState()->getName() != 'fl')
            $html = str_replace('[Primary Residence]','Primary Residence', $html);
        else 
            $html = str_replace('[Primary Residence]','Single family home', $html);

        if ($refinanceGFE->getPrimaryResidence() != null)
        {                
            if ($refinanceGFE->getPrimaryResidence()->getValue())
                $html = str_replace('[PRIMARYRESIDENT]','Yes', $html);
            else 
                $html = str_replace('[PRIMARYRESIDENT]','No', $html);
        }
        else 
            $html = str_replace('[PRIMARYRESIDENT]','', $html);


        $arrloan = $refinanceGFE->getLoanAmounts();
        $countloan = count($arrloan);
        if ($countloan ==1)
        {
            $html = str_replace('[LOAN1]',$this->formatCurrency($arrloan[0]), $html);
            $html = str_replace('[LOAN2]', '', $html);
        }
        else if ($countloan ==2)
        {
            $html = str_replace('[LOAN1]',$this->formatCurrency($arrloan[0]), $html);
            $html = str_replace('[LOAN2]',$this->formatCurrency($arrloan[1]), $html);
        }
        else 
        {
            $html = str_replace('[LOAN1]', '', $html);
            $html = str_replace('[LOAN2]', '', $html);
        }
        
        $arrPayOff = $refinanceGFE->getPayoffs();
        $countPayOff = count($arrPayOff);
        
        if ($refinanceGFE->getState()->getName() != 'va')
        {
            $html = str_replace('[Principal balance #1 to be paid off]','Principal balance #1 to be paid off', $html);
            $html = str_replace('[Principal balance #2 to be paid off]','Principal balance #2 to be paid off', $html);
        }
        else 
        {
            $html = str_replace('[Principal balance #1 to be paid off]','Original first loan balance', $html);
            $html = str_replace('[Principal balance #2 to be paid off]','Original second loan balance', $html);
        }
        
        if ($countPayOff == 1)
        {
            $html = str_replace('[PAIDOFF1]',$this->formatCurrency($arrPayOff[0]->getValue()), $html);
            $html = str_replace('[PAIDOFF2]', '', $html);
        }
        else if ($countPayOff == 2)
        {
            $html = str_replace('[PAIDOFF1]',$this->formatCurrency($arrPayOff[0]->getValue()), $html);
            $html = str_replace('[PAIDOFF2]',$this->formatCurrency($arrPayOff[1]->getValue()), $html);
        }
        else 
        {
            $html = str_replace('[PAIDOFF1]', '', $html);
            $html = str_replace('[PAIDOFF2]', '', $html);
        }
        
        if ($refinanceGFE->getGenericBooleans() != null)
        {
            $strRow = '<tr>
		<td align="right" width="30%">[LABEL]:</td>
		<td width="20%">&nbsp;[VALUE]</td>
		<td width="31%">&nbsp;</td>
		<td width="19%">&nbsp;</td>
	</tr>';
            $gBooleans = $refinanceGFE->getGenericBooleans();
            $strAddRows = '';
            foreach ($gBooleans as $gb)
            {
                $str1 = str_replace('[LABEL]', $gb->getLabel(), $strRow);
                if ($gb->getValue())
                    $str1 = str_replace('[VALUE]', 'Yes', $str1);
                else
                    $str1 = str_replace('[VALUE]', 'No', $str1);
                $strAddRows .= $str1;
            }
            $html = str_replace('[GENERICBOOLEAN]', $strAddRows, $html);        
        }
        else 
            $html = str_replace('[GENERICBOOLEAN]', '', $html);        
                            
        if ($refinanceGFE->getState()->getName() != 'va' && $refinanceGFE->getState()->getName() != 'de')
        {
            $html = str_replace("[Amount of owner's policy]","Amount of owner's policy", $html);
        }
        else 
        {
            $html = str_replace("[Amount of owner's policy]","Policy Amount", $html);
        }
        if ($refinanceGFE->getExistingOwnersPolicy() != null)
            $html = str_replace('[OWNERPOLICY]', $this->formatCurrency($refinanceGFE->getExistingOwnersPolicy()->getValue()), $html);
        else 
            $html = str_replace('[OWNERPOLICY]', '', $html);
        
        $total = 0.0;

        $line1101 = $titleServices + $titleInsuranceCost;
        
        $html = str_replace('[TOTALSERVICE_PAY]',$this->formatCurrency($line1101), $html);        
        
        $total += $line1101;
        
        $html = str_replace('[COMBINE_SERVICE_FEE]',$this->formatCurrency($titleServices), $html);
        
        $html = str_replace('[LENDER_VALUE]',$this->formatCurrency($titleInsuranceCost), $html);

        if ($mobileClosingCost > 0.0) {
            $html = str_replace('[MOBILE_CLOSING]',$this->formatCurrency($mobileClosingCost), $html);
            $total += $mobileClosingCost;
        }
        else 
            $html = str_replace('[MOBILE_CLOSING]', '', $html);

        $grandTotalBuyer += $total;
        $html = str_replace('[TOTAL_INSURANCE_PAY]',$this->formatCurrency($total), $html);
        
         $stateTax = $transferTaxes->getStatePropertyTransferTax();
        $countyTax = $transferTaxes->getCountyPropertyTransferTax();
        $recordationTax = $transferTaxes->getRecordationTax();
        $fees = $transferTaxes->getFees();

        $feesTotal = 0.0;
        //print_r($fees); exit();
        if ($fees != null) 
        {
            foreach ($fees as $fee)
                $feesTotal += $fee->getAmount();            
        }
        $total = $feesTotal;
        $taxTotal = 0.0;
        
        $html = str_replace('[RECORD_FEE_PAY]',$this->formatCurrency($feesTotal), $html);
        
        if ($countyTax != null) {            
            $html = str_replace('[COUNTY_TRANSFER_TAX_PAY]',$this->formatCurrency($countyTax->getAmount()), $html);
            $taxTotal += $countyTax->getAmount();
        }
        else 
            $html = str_replace('[COUNTY_TRANSFER_TAX_PAY]', '', $html);
        
        if ($stateTax != null) {
            $html = str_replace('[STATE_TRANSFER_TAX_PAY]',$this->formatCurrency($stateTax->getAmount()), $html);
            $taxTotal += $stateTax->getAmount();
        }
        else
            $html = str_replace('[STATE_TRANSFER_TAX_PAY]', '', $html);
        
        if ($recordationTax != null) {
            $html = str_replace('[RECODATION_TAX_PAY]',$this->formatCurrency($recordationTax->getAmount()), $html);
            $taxTotal += $recordationTax->getAmount();
        }
        else
            $html = str_replace('[RECODATION_TAX_PAY]', '', $html);
        
        $html = str_replace('[GOV_TAX_PAY]',$this->formatCurrency($taxTotal), $html);
        $total += $taxTotal;

        $html = str_replace('[TOTAL_GOV_RECODING_TRANSFER]',$this->formatCurrency($total), $html);
        $grandTotalBuyer += $total;
        
        $html = str_replace('[ALL_TOTAL]',$this->formatCurrency($grandTotalBuyer), $html);
        
        //echo $html; exit();
        
        $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
        // set document information
        $pdf->SetCreator(PDF_CREATOR);
        $pdf->SetAuthor('Danh');
        $pdf->SetTitle('TCPDF Table');
        $pdf->SetSubject('TCPDF Tutorial');
        $pdf->SetKeywords('TCPDF, PDF, example, test, guide');            
        // set header and footer fonts
        $pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
        $pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
        // set default monospaced font
        $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
        //set margins
        $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
        $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
        $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
        //set auto page breaks
        $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
        //set image scale factor
        //set some language-dependent strings
        //$pdf->setLanguageArray($l);
        // ---------------------------------------------------------
        // set font
        $pdf->SetFont('dejavusans', '', 8);
        // add a page
        $pdf->AddPage();		
        $pdf->writeHTML($html, true, true, true, false, '');
        $pdf->lastPage();		
        $pdf->Output($this->type.$refinanceGFE->getState()->getValue().".pdf", 'I');        
       }        
       
  }//Ket thuc class
?>
